package com.itheima.controller;


import com.itheima.pojo.Adress;
import com.itheima.pojo.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class ResponseController {
//    @RequestMapping("/hello")
//    public String hello(){
//        System.out.println("hello");
//        return "hello word";
//    }
//
//    @RequestMapping("/address")
//    public Adress getAdress(){
//        Adress adress = new Adress();
//        adress.setProvince("北京");
//        adress.setCity("北京");
//        return adress;
//    }
//
//    @RequestMapping("/listAddress")
//    public List<Adress> listAddress(){
//        List<Adress> list = new ArrayList<>();
//        Adress address = new Adress();
//        address.setProvince("北京");
//        address.setCity("北京");
//        Adress add2 = new Adress();
//        add2.setProvince("上海");
//        add2.setCity("上海");
//        list.add(address);
//        list.add(add2);
//        return list;
//
//    }



    @RequestMapping("/hello")
    public Result hello(){
        System.out.println("hello");
//        return new Result(200,"success","hello word");
        return  Result.success("hello word");


    }

    @RequestMapping("/address")
    public Result getAdress(){
        Adress adress = new Adress();
        adress.setProvince("北京");
        adress.setCity("北京");
        return Result.success(
                adress
        );
    }

    @RequestMapping("/listAddress")
    public Result listAddress(){
        List<Adress> list = new ArrayList<>();
        Adress address = new Adress();
        address.setProvince("北京");
        address.setCity("北京");
        Adress add2 = new Adress();
        add2.setProvince("上海");
        add2.setCity("上海");
        list.add(address);
        list.add(add2);
        return Result.success(list);

    }

}
